/****************************************************************
 * Fulguro
 * Copyright (C) 2004 Christophe Clienti
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 ***************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "flgrCoreMalloc.h"
#include "flgrCoreDispatch.h"
#include "flgrCoreVector.h"
#include "flgrCoreIO.h"

/*!
 * \addtogroup group_fulguro_core_vector
 * @{
 */

/*
 * fgBIT in vector is a bit special (there is no hidden joke ...), 
 * the store method is different from that used in FLGR_DataXD.
 * In fact bit pixels are stored as those of fgUINT32. One bit used
 * one fgUINT32 memory cell. This facilitates computation over
 * each elements of the vector
 *
 */
   


//////////////////////////////////////////////////////////////////
/*! Allocate Vector Structure
 *  @param spp  : Vector Size (number of elements)
 *  @param type : type of vector elements
 *  @returns pointer to FLGR_Vector or NULL if allocation failed
 */
//////////////////////////////////////////////////////////////////
FLGR_Vector *flgr_vector_create(int spp, FLGR_Type type){
  FLGR_Vector *vct;

  FLGR_DECLARE_FUNCTION;

  if(flgr_is_vector_type_valid(type)!=FLGR_RET_OK) {
    POST_ERROR("unknwon type\n");
    return NULL;
  }
  
  if(spp<1) {
    POST_ERROR("Sample Per Pixel (spp) cannot be < 1\n");
    return NULL; 
  }

  vct = flgr_malloc(sizeof(FLGR_Vector));

  vct->bps = flgr_get_bps_from_type(type);
  vct->spp = spp;
  vct->type = type;

  vct->array = flgr_malloc_align((spp*vct->bps)/8+16,16);

  if(vct->array == NULL) {
    POST_ERROR("Allocation error !\n");
    flgr_free(vct);
    return NULL;
  }

  return vct;
}

//////////////////////////////////////////////////////////////////
/*! Destroy Vector Structure
 *  @param vct : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_destroy(FLGR_Vector *vct) {
  FLGR_DECLARE_FUNCTION;

  if(vct == NULL) {
    POST_ERROR("Null object\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if(vct->array == NULL) {
    POST_ERROR("Vector array is null\n");
    return FLGR_RET_NULL_OBJECT;
  }

  flgr_free_align(vct->array);

  flgr_free(vct);
 
  

  return FLGR_RET_OK;
}


//////////////////////////////////////////////////////////////////
/*! Clear all vector elements (set to 0)
 *  @param vct : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_clear(FLGR_Vector *vct) {
  FLGR_DECLARE_FUNCTION;

  if(vct == NULL) {
    POST_ERROR("Null object\n");
    return FLGR_RET_NULL_OBJECT;
  }
  
  memset(vct->array, 0, vct->spp*(vct->bps>>3));
  return FLGR_RET_OK;
}


//////////////////////////////////////////////////////////////////
// macro for different type of flgr_vector_get_element
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_GET_ELEMENT(dtype)			\
  FLGR_DECLARE_FUNCTION;					\
  *value= flgr_get_array_##dtype((dtype*) (vct->array),index)

void flgr_vector_get_element_fgBIT(FLGR_Vector *vct, int index, fgBIT *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgBIT);
}
void flgr_vector_get_element_fgUINT8(FLGR_Vector *vct, int index, fgUINT8 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgUINT8);
}
void flgr_vector_get_element_fgUINT16(FLGR_Vector *vct, int index, fgUINT16 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgUINT16);
}
void flgr_vector_get_element_fgUINT32(FLGR_Vector *vct, int index, fgUINT32 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgUINT32);
}
void flgr_vector_get_element_fgUINT64(FLGR_Vector *vct, int index, fgUINT64 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgUINT64);
}
void flgr_vector_get_element_fgINT8(FLGR_Vector *vct, int index, fgINT8 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgINT8);
}
void flgr_vector_get_element_fgINT16(FLGR_Vector *vct, int index, fgINT16 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgINT16);
}
void flgr_vector_get_element_fgINT32(FLGR_Vector *vct, int index, fgINT32 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgINT32);
}
void flgr_vector_get_element_fgINT64(FLGR_Vector *vct, int index, fgINT64 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgINT64);
}
void flgr_vector_get_element_fgFLOAT32(FLGR_Vector *vct, int index, fgFLOAT32 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgFLOAT32);
}
void flgr_vector_get_element_fgFLOAT64(FLGR_Vector *vct, int index, fgFLOAT64 *value) {
  FLGR_MACRO_VECTOR_GET_ELEMENT(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! Get one element inside a vector
 *  @param vct : pointer to FLGR_Vector
 *  @param index : index of the element
 *  @param value : pointer to an allocated variable with the right type regarding vct->type
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_get_element(FLGR_Vector *vct, int index, void *value) {
  FLGR_DECLARE_FUNCTION;

  if(vct==NULL) {
    POST_ERROR("Null Objects\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((index<0) || (index>=vct->spp)) {
    POST_ERROR("index (%d) out of the vector\n",index);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_FULL_DISPATCH_CONST_PTR_PROCEDURE(vct->type, flgr_vector_get_element, value, vct, index);
}



//////////////////////////////////////////////////////////////////
// macro for different type of flgr_vector_get_element
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_REVERT_ELEMENT(dtype)		\
  int k,l;						\
  int spp = vctdest->spp;				\
  dtype *psrc = (dtype*) vctsrc->array;			\
  dtype *pdest = (dtype*) vctdest->array;		\
  dtype a1;						\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  for(k=0,l=spp-1 ; k<spp ; k++,l--) {			\
    a1 = flgr_get_array_##dtype(psrc,k);		\
    flgr_set_array_##dtype(pdest,l,a1);			\
  }							\
  return

void flgr_vector_revert_element_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgBIT);
}
void flgr_vector_revert_element_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgUINT8);
}
void flgr_vector_revert_element_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgUINT16);
}
void flgr_vector_revert_element_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgUINT32);
}
void flgr_vector_revert_element_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgUINT64);
}
void flgr_vector_revert_element_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgINT8);
}
void flgr_vector_revert_element_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgINT16);
}
void flgr_vector_revert_element_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgINT32);
}
void flgr_vector_revert_element_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgINT64);
}
void flgr_vector_revert_element_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgFLOAT32);
}
void flgr_vector_revert_element_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_REVERT_ELEMENT(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! revert all elements
 *  @param vctdest : pointer to FLGR_Vector
 *  @param vctsrc : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_revert_element(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((vctdest==NULL) || (vctsrc==NULL)) {
    POST_ERROR("Null Objects\n");
    return FLGR_RET_NULL_OBJECT;
  }

  ret = flgr_vector_is_same_type(vctsrc,vctdest);
  if(ret != FLGR_RET_OK) {
    POST_ERROR("Vector type different !\n");
    return FLGR_RET_TYPE_DIFFERENT;
  }

  ret = flgr_vector_is_same_spp(vctdest,vctsrc);
  if(ret != FLGR_RET_OK) {
    POST_ERROR("Vector SPP different !\n");
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_FULL_PROCEDURE_DISPATCH(vctdest->type, flgr_vector_revert_element, vctdest, vctsrc);

}









//////////////////////////////////////////////////////////////////
// macro for different type of flgr_vector_get_element
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_SET_ELEMENT(dtype)				\
  FLGR_DECLARE_FUNCTION;						\
  flgr_set_array_##dtype((dtype*) (vct->array),index,value)	

void flgr_vector_set_element_fgBIT(FLGR_Vector *vct, int index, fgBIT value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgBIT);
}
void flgr_vector_set_element_fgUINT8(FLGR_Vector *vct, int index, fgUINT8 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgUINT8);
}
void flgr_vector_set_element_fgUINT16(FLGR_Vector *vct, int index, fgUINT16 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgUINT16);
}
void flgr_vector_set_element_fgUINT32(FLGR_Vector *vct, int index, fgUINT32 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgUINT32);
}
void flgr_vector_set_element_fgUINT64(FLGR_Vector *vct, int index, fgINT64 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgUINT64);
}
void flgr_vector_set_element_fgINT8(FLGR_Vector *vct, int index, fgINT8 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgINT8);
}
void flgr_vector_set_element_fgINT16(FLGR_Vector *vct, int index, fgINT16 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgINT16);
}
void flgr_vector_set_element_fgINT32(FLGR_Vector *vct, int index, fgINT32 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgINT32);
}
void flgr_vector_set_element_fgINT64(FLGR_Vector *vct, int index, fgINT64 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgINT64);
}
void flgr_vector_set_element_fgFLOAT32(FLGR_Vector *vct, int index, fgFLOAT32 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgFLOAT32);
}
void flgr_vector_set_element_fgFLOAT64(FLGR_Vector *vct, int index, fgFLOAT64 value) {
  FLGR_MACRO_VECTOR_SET_ELEMENT(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! Set one element inside a vector
 *  @param vct : pointer to FLGR_Vector
 *  @param index : index of the element
 *  @param value : pointer to an allocated variable with the right type regarding vct->type
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_set_element(FLGR_Vector *vct, int index, void *value) {
  FLGR_DECLARE_FUNCTION;

  if(vct==NULL) {
    POST_ERROR("Null Objects\n");
    return FLGR_RET_NULL_OBJECT;
  }

  if((index<0) || (index>=vct->spp)) {
    POST_ERROR("index (%d) out of the vector\n",index);
    return FLGR_RET_UNDEFINED_ERROR;
  }

  FLGR_FULL_DISPATCH_CONST_PROCEDURE(vct->type, flgr_vector_set_element, value, vct, index);
}








//////////////////////////////////////////////////////////////////
// Macro for different type of flgr_vector_import_raw 
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_IMPORT_RAW(dtype)	\
  dtype *array_d = (dtype*) vctdest->array;	\
  dtype *array_s = (dtype*) raw_src;		\
  int i;					\
  dtype val;					\
						\
  FLGR_DECLARE_FUNCTION;			\
						\
  for(i=0 ; i<vctdest->spp ; i++) {		\
    val = flgr_get_array_##dtype(array_s,i);	\
    flgr_set_array_##dtype(array_d,i,val);	\
  }						\
						\
  return

void flgr_vector_import_raw_fgBIT(FLGR_Vector *vctdest, void *raw_src) {
  fgBIT *array_d = (fgBIT*) vctdest->array;
  fgBIT *array_s = (fgBIT*) raw_src;
  int i;
  fgBIT val;

  FLGR_DECLARE_FUNCTION;

  for(i=0 ; i<vctdest->spp ; i++) {
    val = array_s[i];
    flgr_set_array_fgBIT(array_d,i,val);
  }
}
void flgr_vector_import_raw_fgUINT8(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgUINT8);
}
void flgr_vector_import_raw_fgUINT16(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgUINT16);
}
void flgr_vector_import_raw_fgUINT32(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgUINT32);
}
void flgr_vector_import_raw_fgUINT64(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgUINT64);
}
void flgr_vector_import_raw_fgINT8(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgINT8);
}
void flgr_vector_import_raw_fgINT16(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgINT16);
}
void flgr_vector_import_raw_fgINT32(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgINT32);
}
void flgr_vector_import_raw_fgINT64(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgINT64);
}
void flgr_vector_import_raw_fgFLOAT32(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgFLOAT32);
}
void flgr_vector_import_raw_fgFLOAT64(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_MACRO_VECTOR_IMPORT_RAW(fgFLOAT64);
}

//////////////////////////////////////////////////////////////////
/*! Copy raw to Vector array
 *
 *  Number of element in raw must correspond to number of element in the vector
 *  @param vctdest : pointer to FLGR_Vector
 *  @param raw_src : pointer to raw array with the right type regarding vector type
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_import_raw(FLGR_Vector *vctdest, void *raw_src) {
  FLGR_DECLARE_FUNCTION;

  if(vctdest==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }

  FLGR_FULL_PROCEDURE_DISPATCH(vctdest->type, flgr_vector_import_raw, vctdest, raw_src);

  return FLGR_RET_OK;
}






//////////////////////////////////////////////////////////////////
// Macro for different type of flgr_vector_import_string
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_IMPORT_STRING(dtype,dtype_scan,motif)		\
  int k;								\
  dtype *dest = (dtype*) vctdest->array;				\
  dtype_scan var;							\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(k=0 ; k<vctdest->spp ; k++) {					\
    sscanf(string_src,motif,&var);					\
    flgr_set_array_##dtype(dest,k,(dtype) var);				\
    while((*string_src!=' ') && (*string_src!='\0')) string_src++;	\
  }									\
  return

void flgr_vector_import_string_fgBIT(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgBIT,fgUINT32,"%d");
}
void flgr_vector_import_string_fgUINT8(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgUINT8,fgUINT32,"%d");
}
void flgr_vector_import_string_fgUINT16(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgUINT16,fgUINT32,"%d");
}
void flgr_vector_import_string_fgUINT32(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgUINT32,fgUINT32,"%d");
}
void flgr_vector_import_string_fgUINT64(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgUINT64,fgUINT64,"%Ld");
}
void flgr_vector_import_string_fgINT8(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgINT8,fgINT32,"%d");
}
void flgr_vector_import_string_fgINT16(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgINT16,fgINT32,"%d");
}
void flgr_vector_import_string_fgINT32(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgINT32,fgINT32,"%d");
}
void flgr_vector_import_string_fgINT64(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgINT64,fgINT64,"%Ld");
}
void flgr_vector_import_string_fgFLOAT32(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgFLOAT32,fgFLOAT32,"%f");
}
void flgr_vector_import_string_fgFLOAT64(FLGR_Vector *vctdest, char *string_src) {
  FLGR_MACRO_VECTOR_IMPORT_STRING(fgFLOAT64,fgFLOAT64,"%lf");
}
//////////////////////////////////////////////////////////////////
/*! Copy string (populated with decimal numbers) to the vector
 *
 *  Example : flgr_vector_import_string(vct, "10.3 11 12") 
 *  will put elements [10.3, 11, 12] in the vector float array
 *
 *  @param vctdest : pointer to FLGR_Vectortype of vector elements
 *  @param string_src : string
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_import_string(FLGR_Vector *vctdest, char *string_src) {
  FLGR_DECLARE_FUNCTION;

  if(vctdest==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }

  FLGR_FULL_PROCEDURE_DISPATCH(vctdest->type, flgr_vector_import_string, vctdest, string_src);
}





//////////////////////////////////////////////////////////////////
// Macro for different type of flgr_vector_export_raw 
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_EXPORT_RAW(dtype)	\
  dtype *array_d = (dtype*) raw_dest;		\
  dtype *array_s = (dtype*) vctsrc->array;	\
  int i;					\
  dtype val;					\
						\
  FLGR_DECLARE_FUNCTION;			\
						\
  for(i=0 ; i<vctsrc->spp ; i++) {		\
    val = flgr_get_array_##dtype(array_s,i);	\
    flgr_set_array_##dtype(array_d,i,val);	\
  }						\
						\
  return

void flgr_vector_export_raw_fgBIT(void *raw_dest, FLGR_Vector *vctsrc) {
  fgBIT *array_d = (fgBIT*) raw_dest;
  fgBIT *array_s = (fgBIT*) vctsrc->array;
  int i;
  fgBIT val;

  FLGR_DECLARE_FUNCTION;

  for(i=0 ; i<vctsrc->spp ; i++) {
    val = flgr_get_array_fgBIT(array_s,i);
    array_d[i]=val;
  }
}
void flgr_vector_export_raw_fgUINT8(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgUINT8);
}
void flgr_vector_export_raw_fgUINT16(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgUINT16);
}
void flgr_vector_export_raw_fgUINT32(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgUINT32);
}
void flgr_vector_export_raw_fgUINT64(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgUINT64);
}
void flgr_vector_export_raw_fgINT8(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgINT8);
}
void flgr_vector_export_raw_fgINT16(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgINT16);
}
void flgr_vector_export_raw_fgINT32(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgINT32);
}
void flgr_vector_export_raw_fgINT64(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgINT64);
}
void flgr_vector_export_raw_fgFLOAT32(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgFLOAT32);
}
void flgr_vector_export_raw_fgFLOAT64(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_EXPORT_RAW(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! Copy vector to Vector array
 *
 *  Number of element in raw must correspond to number of element in the vector
 *  @param vctsrc : pointer to FLGR_Vector
 *  @param raw_dest : pointer to raw array, type must fit with vector type
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_export_raw(void *raw_dest, FLGR_Vector *vctsrc) {
  FLGR_DECLARE_FUNCTION;

  if(vctsrc==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }
  FLGR_FULL_PROCEDURE_DISPATCH(vctsrc->type,flgr_vector_export_raw,raw_dest,vctsrc);
}






/////////////////////////////////////////////////////////////////
// macro for different type of flgr_vector_populate_from_scalar
/////////////////////////////////////////////////////////////////
#define FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(dtype)	\
  int k;						\
  dtype *vctar = (dtype*) vctdest->array;		\
							\
  FLGR_DECLARE_FUNCTION;				\
							\
  for(k=0 ; k<vctdest->spp ; k++) {			\
    flgr_set_array_##dtype(vctar,k,scalar);		\
  }							\
  return

void flgr_vector_populate_from_scalar_fgBIT(FLGR_Vector *vctdest, fgBIT scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgBIT);
}
void flgr_vector_populate_from_scalar_fgUINT8(FLGR_Vector *vctdest, fgUINT8 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgUINT8);
}
void flgr_vector_populate_from_scalar_fgUINT16(FLGR_Vector *vctdest, fgUINT16 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgUINT16);
}
void flgr_vector_populate_from_scalar_fgUINT32(FLGR_Vector *vctdest, fgUINT32 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgUINT32);
}
void flgr_vector_populate_from_scalar_fgUINT64(FLGR_Vector *vctdest, fgUINT64 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgUINT64);
}
void flgr_vector_populate_from_scalar_fgINT8(FLGR_Vector *vctdest, fgINT8 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgINT8);
}
void flgr_vector_populate_from_scalar_fgINT16(FLGR_Vector *vctdest, fgINT16 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgINT16);
}
void flgr_vector_populate_from_scalar_fgINT32(FLGR_Vector *vctdest, fgINT32 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgUINT32);
}
void flgr_vector_populate_from_scalar_fgINT64(FLGR_Vector *vctdest, fgINT64 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgINT64);
}
void flgr_vector_populate_from_scalar_fgFLOAT32(FLGR_Vector *vctdest, fgFLOAT32 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgFLOAT32);
}
void flgr_vector_populate_from_scalar_fgFLOAT64(FLGR_Vector *vctdest, fgFLOAT64 scalar) {
  FLGR_MACRO_FLGR_VECTOR_POPULATE_SCALAR(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! Copy a scalar in each elements of a vector
 *  @param vctdest : pointer to FLGR_Vector
 *  @param scalar : pointer to scalar, type must fit with vector type
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_populate_from_scalar(FLGR_Vector *vctdest, void *scalar) {
  FLGR_DECLARE_FUNCTION;


  if(vctdest==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }

  switch(vctdest->type) {
  case FLGR_BIT:
    flgr_vector_populate_from_scalar_fgBIT(vctdest, FLGR_PVOID_VAL(fgBIT,scalar)); break;

  case FLGR_UINT8:
    flgr_vector_populate_from_scalar_fgUINT8(vctdest, FLGR_PVOID_VAL(fgUINT8,scalar)); break;

  case FLGR_UINT16:
    flgr_vector_populate_from_scalar_fgUINT16(vctdest, FLGR_PVOID_VAL(fgUINT16,scalar)); break;

  case FLGR_UINT32:
    flgr_vector_populate_from_scalar_fgUINT32(vctdest, FLGR_PVOID_VAL(fgUINT32,scalar)); break;

  case FLGR_UINT64:
    flgr_vector_populate_from_scalar_fgUINT64(vctdest, FLGR_PVOID_VAL(fgUINT64,scalar)); break;

  case FLGR_INT8:
    flgr_vector_populate_from_scalar_fgINT8(vctdest, FLGR_PVOID_VAL(fgINT8,scalar)); break;

  case FLGR_INT16:
    flgr_vector_populate_from_scalar_fgINT16(vctdest, FLGR_PVOID_VAL(fgINT16,scalar)); break;

  case FLGR_INT32:
    flgr_vector_populate_from_scalar_fgINT32(vctdest, FLGR_PVOID_VAL(fgINT32,scalar)); break;

  case FLGR_INT64:
    flgr_vector_populate_from_scalar_fgINT64(vctdest, FLGR_PVOID_VAL(fgINT64,scalar)); break;

  case FLGR_FLOAT32:
    flgr_vector_populate_from_scalar_fgFLOAT32(vctdest, FLGR_PVOID_VAL(fgFLOAT32,scalar)); break;

  case FLGR_FLOAT64:
    flgr_vector_populate_from_scalar_fgFLOAT64(vctdest, FLGR_PVOID_VAL(fgFLOAT64,scalar)); break;

  default:
    POST_ERROR("Type unknow\n");
    return FLGR_RET_TYPE_UNKNOWN;
  }

  return FLGR_RET_OK;
}

//////////////////////////////////////////////////////////////////
/*! convert a string to the right type and copy it to each elements of a vector
 *  @param vctdest    : pointer to FLGR_Vector
 *  @param string_val : pointer to string
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_populate_from_string(FLGR_Vector *vctdest, char *string_val) {
  fgUINT64 val_fixed;
  fgFLOAT64 val_float;

  FLGR_DECLARE_FUNCTION;

  if(vctdest==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }

  if(strlen(string_val) <= 0) {
    POST_ERROR("Null string\n");
    return FLGR_RET_UNDEFINED_ERROR;
  }

  sscanf(string_val,"%Ld",&val_fixed);
  sscanf(string_val,"%lf",&val_float);

  switch(vctdest->type) {
  case FLGR_BIT:
    flgr_vector_populate_from_scalar_fgBIT(vctdest, (fgBIT) val_fixed); break;

  case FLGR_UINT8:
    flgr_vector_populate_from_scalar_fgUINT8(vctdest, (fgUINT8) val_fixed); break;

  case FLGR_UINT16:
    flgr_vector_populate_from_scalar_fgUINT16(vctdest, (fgUINT16) val_fixed); break;

  case FLGR_UINT32:
    flgr_vector_populate_from_scalar_fgUINT32(vctdest, (fgUINT32) val_fixed); break;

  case FLGR_UINT64:
    flgr_vector_populate_from_scalar_fgUINT64(vctdest, (fgUINT64) val_fixed); break;

  case FLGR_INT8:
    flgr_vector_populate_from_scalar_fgINT8(vctdest, (fgINT8) val_fixed); break;

  case FLGR_INT16:
    flgr_vector_populate_from_scalar_fgINT16(vctdest, (fgINT16) val_fixed); break;

  case FLGR_INT32:
    flgr_vector_populate_from_scalar_fgINT32(vctdest, (fgINT32) val_fixed); break;

  case FLGR_INT64:
    flgr_vector_populate_from_scalar_fgINT64(vctdest, (fgINT64) val_fixed); break;

  case FLGR_FLOAT32:
    flgr_vector_populate_from_scalar_fgFLOAT32(vctdest, (fgFLOAT32) val_float); break;

  case FLGR_FLOAT64:
    flgr_vector_populate_from_scalar_fgFLOAT64(vctdest, (fgFLOAT64) val_float); break;

  default:
    POST_ERROR("Type unknow\n");
    return FLGR_RET_TYPE_UNKNOWN;
  }

  return FLGR_RET_OK;
}







//////////////////////////////////////////////////////////////////
// macro for flgr_vector_is_zero
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_IS_ZERO(dtype)	\
  dtype *ar = (dtype*) vct->array;		\
  int i,spp=vct->spp;				\
  dtype v;					\
						\
  FLGR_DECLARE_FUNCTION;			\
						\
  for(i=0 ; i<spp ; i++) {			\
    v = flgr_get_array_##dtype(ar,i);		\
    if(v != 0) return FLGR_FALSE;		\
  }						\
						\
  return FLGR_TRUE

int flgr_vector_is_zero_fgBIT(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgBIT);
}
int flgr_vector_is_zero_fgUINT8(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgUINT8);
}
int flgr_vector_is_zero_fgUINT16(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgUINT16);
}
int flgr_vector_is_zero_fgUINT32(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgUINT32);
}
int flgr_vector_is_zero_fgUINT64(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgUINT64);
}
int flgr_vector_is_zero_fgINT8(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgINT8);
}
int flgr_vector_is_zero_fgINT16(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgINT16);
}
int flgr_vector_is_zero_fgINT32(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgINT32);
}
int flgr_vector_is_zero_fgINT64(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgINT64);
}
int flgr_vector_is_zero_fgFLOAT32(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgFLOAT32);
}
int flgr_vector_is_zero_fgFLOAT64(FLGR_Vector *vct) {
  FLGR_MACRO_VECTOR_IS_ZERO(fgFLOAT64);
}
//////////////////////////////////////////////////////////////////
/*! Return true if all vector elements are equal to zero
 *  @param vct    : pointer to FLGR_Vector
 *  @returns FLGR_FALSE, FLGR_TRUE
 */
//////////////////////////////////////////////////////////////////
int flgr_vector_is_zero(FLGR_Vector *vct) {
  FLGR_DECLARE_FUNCTION;

  if(vct==NULL) {
    POST_ERROR("Null object\n");
    return FLGR_FALSE;
  }
  FLGR_FULL_FUNCTION_DISPATCH(FLGR_FALSE,vct->type, flgr_vector_is_zero, vct);
}








//////////////////////////////////////////////////////////////////
// macro for flgr_vector_equal
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_EQUAL(dtype)				\
  dtype *ar1 = (dtype*) vct1->array;				\
  dtype *ar2 = (dtype*) vct2->array;				\
  int i,spp=vct1->spp;						\
  dtype v1,v2;							\
								\
  FLGR_DECLARE_FUNCTION;					\
								\
  for(i=0 ; i<spp ; i++) {					\
    v1 = flgr_get_array_##dtype(ar1,i);				\
    v2 = flgr_get_array_##dtype(ar2,i);				\
    								\
    if(v1 != v2) return FLGR_FALSE;				\
  }								\
								\
  return FLGR_TRUE

int flgr_vector_equal_fgBIT(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgBIT);
}
int flgr_vector_equal_fgUINT8(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgUINT8);
}
int flgr_vector_equal_fgUINT16(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgUINT16);
}
int flgr_vector_equal_fgUINT32(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgUINT32);
}
int flgr_vector_equal_fgUINT64(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgUINT64);
}
int flgr_vector_equal_fgINT8(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgINT8);
}
int flgr_vector_equal_fgINT16(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgINT16);
}
int flgr_vector_equal_fgINT32(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgINT32);
}
int flgr_vector_equal_fgINT64(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgINT64);
}
int flgr_vector_equal_fgFLOAT32(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgFLOAT32);
}
int flgr_vector_equal_fgFLOAT64(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_MACRO_VECTOR_EQUAL(fgFLOAT64);
}

//////////////////////////////////////////////////////////////////
/*! Check if two vector are equal
 *
 * if vectors have different spp or types, the result will be FLGR_FALSE
 *
 *  @param vct1    : pointer to FLGR_Vector
 *  @param vct2    : pointer to FLGR_Vector
 *  @returns FLGR_FALSE, FLGR_TRUE
 */
//////////////////////////////////////////////////////////////////
int flgr_vector_equal(FLGR_Vector *vct1, FLGR_Vector *vct2) {

  FLGR_DECLARE_FUNCTION;

  if(flgr_vector_is_type_valid(vct1) != FLGR_RET_OK) return FLGR_FALSE;
  if(flgr_vector_is_same_type(vct1, vct2) != FLGR_RET_OK) return FLGR_FALSE;
  if(flgr_vector_is_same_spp(vct1, vct2) != FLGR_RET_OK) return FLGR_FALSE;

  FLGR_FULL_FUNCTION_DISPATCH(FLGR_FALSE,vct1->type,flgr_vector_equal,vct1,vct2);
}








//////////////////////////////////////////////////////////////////
/*! Check if a vector type is valid
 *  @param vct    : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_is_type_valid(FLGR_Vector *vct) {
  FLGR_DECLARE_FUNCTION;

  if(vct==NULL) {
    return FLGR_RET_NULL_OBJECT;
  }

  switch(vct->type) {
  case FLGR_BIT:     return FLGR_RET_OK;
  case FLGR_UINT8:   return FLGR_RET_OK;
  case FLGR_UINT16:  return FLGR_RET_OK;
  case FLGR_UINT32:  return FLGR_RET_OK;
  case FLGR_UINT64:  return FLGR_RET_OK;
  case FLGR_INT8:    return FLGR_RET_OK;
  case FLGR_INT16:   return FLGR_RET_OK;
  case FLGR_INT32:   return FLGR_RET_OK;
  case FLGR_INT64:   return FLGR_RET_OK;
  case FLGR_FLOAT32: return FLGR_RET_OK;
  case FLGR_FLOAT64: return FLGR_RET_OK;
  default:
    return FLGR_RET_TYPE_UNKNOWN;
  }
  return FLGR_RET_OK;
}

//////////////////////////////////////////////////////////////////
/*! Check if two vectors have same type
 *  @param vct1 : pointer to FLGR_Vector
 *  @param vct2 : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_is_same_type(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((vct1==NULL) || (vct2==NULL)) {
    return FLGR_RET_NULL_OBJECT;
  }

  if((ret=flgr_vector_is_type_valid(vct1))!=FLGR_RET_OK) return ret;
  if((ret=flgr_vector_is_type_valid(vct2))!=FLGR_RET_OK) return ret;

  if(vct1->type != vct2->type) {
    return FLGR_RET_TYPE_DIFFERENT;
  }
  
  return FLGR_RET_OK;
}

//////////////////////////////////////////////////////////////////
/*! Check if two vectors have same Sample Per Pixel
 *  @param vct1 : pointer to FLGR_Vector
 *  @param vct2 : pointer to FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_is_same_spp(FLGR_Vector *vct1, FLGR_Vector *vct2) {
  FLGR_DECLARE_FUNCTION;

  if((vct1==NULL) || (vct2==NULL)) {
    return FLGR_RET_NULL_OBJECT;
  }

  if(vct1->spp != vct2->spp) {
    return FLGR_RET_SIZE_ERROR;
  }

  return FLGR_RET_OK;
}






int flgr_vector_is_type_fgBIT(FLGR_Vector *vct) {
  return (vct->type==FLGR_BIT);
}

int flgr_vector_is_type_fgUINT8(FLGR_Vector *vct) {
  return (vct->type==FLGR_UINT8);
}

int flgr_vector_is_type_fgUINT16(FLGR_Vector *vct) {
  return (vct->type==FLGR_UINT16);
}

int flgr_vector_is_type_fgUINT32(FLGR_Vector *vct) {
  return (vct->type==FLGR_UINT32);
}

int flgr_vector_is_type_fgUINT64(FLGR_Vector *vct) {
  return (vct->type==FLGR_UINT64);
}

int flgr_vector_is_type_fgINT8(FLGR_Vector *vct) {
  return (vct->type==FLGR_INT8);
}

int flgr_vector_is_type_fgINT16(FLGR_Vector *vct) {
  return (vct->type==FLGR_INT16);
}

int flgr_vector_is_type_fgINT32(FLGR_Vector *vct) {
  return (vct->type==FLGR_INT32);
}

int flgr_vector_is_type_fgINT64(FLGR_Vector *vct) {
  return (vct->type==FLGR_INT64);
}

int flgr_vector_is_type_fgFLOAT32(FLGR_Vector *vct) {
  return (vct->type==FLGR_FLOAT32);
}

int flgr_vector_is_type_fgFLOAT64(FLGR_Vector *vct) {
  return (vct->type==FLGR_FLOAT64);
}














//////////////////////////////////////////////////////////////////
// Macro for different type of flgr_vector_copy
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(dtype_dest, dtype_src)	\
  int k;								\
  int spp = vctdest->spp;						\
  dtype_src *psrc = (dtype_src*) vctsrc->array;				\
  dtype_dest *pdest = (dtype_dest*) vctdest->array;			\
  dtype_dest v;								\
									\
  FLGR_DECLARE_FUNCTION;						\
									\
  for(k=0 ; k<spp ; k++) {						\
    v = (dtype_dest) flgr_get_array_##dtype_src(psrc,k);		\
    flgr_set_array_##dtype_dest(pdest,k,v);				\
  }									\
									\
  return

#define FLGR_MACRO_VECTOR_COPY(dtype)				\
  int spp = vctdest->spp;					\
  int bps = vctdest->bps;					\
								\
  FLGR_DECLARE_FUNCTION;					\
								\
  memcpy(vctdest->array, vctsrc->array, (spp*bps)/8+16);	\
								\
  return

void flgr_vector_copy_fgBIT_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgBIT);
}
void flgr_vector_copy_fgBIT_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgUINT8);
}
void flgr_vector_copy_fgBIT_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgUINT16);
}
void flgr_vector_copy_fgBIT_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgUINT32);
}
void flgr_vector_copy_fgBIT_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgUINT64);
}
void flgr_vector_copy_fgBIT_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgINT8);
}
void flgr_vector_copy_fgBIT_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgINT16);
}
void flgr_vector_copy_fgBIT_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgINT32);
}
void flgr_vector_copy_fgBIT_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgINT64);
}
void flgr_vector_copy_fgBIT_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgFLOAT32);
}
void flgr_vector_copy_fgBIT_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgBIT,fgFLOAT64);
}


void flgr_vector_copy_fgUINT8_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgBIT);
}
void flgr_vector_copy_fgUINT8_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgUINT8);
}
void flgr_vector_copy_fgUINT8_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgUINT16);
}
void flgr_vector_copy_fgUINT8_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgUINT32);
}
void flgr_vector_copy_fgUINT8_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgUINT64);
}
void flgr_vector_copy_fgUINT8_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgINT8);
}
void flgr_vector_copy_fgUINT8_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgINT16);
}
void flgr_vector_copy_fgUINT8_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgINT32);
}
void flgr_vector_copy_fgUINT8_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgINT64);
}
void flgr_vector_copy_fgUINT8_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgFLOAT32);
}
void flgr_vector_copy_fgUINT8_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT8,fgFLOAT64);
}


void flgr_vector_copy_fgUINT16_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16, fgBIT);
}
void flgr_vector_copy_fgUINT16_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgUINT8);
}
void flgr_vector_copy_fgUINT16_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgUINT16);
}
void flgr_vector_copy_fgUINT16_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgUINT32);
}
void flgr_vector_copy_fgUINT16_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgUINT64);
}
void flgr_vector_copy_fgUINT16_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgINT8);
}
void flgr_vector_copy_fgUINT16_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgINT16);
}
void flgr_vector_copy_fgUINT16_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgINT32);
}
void flgr_vector_copy_fgUINT16_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgINT64);
}
void flgr_vector_copy_fgUINT16_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgFLOAT32);
}
void flgr_vector_copy_fgUINT16_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT16,fgFLOAT64);
}



void flgr_vector_copy_fgUINT32_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32, fgBIT);
}
void flgr_vector_copy_fgUINT32_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgUINT8);
}
void flgr_vector_copy_fgUINT32_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32, fgUINT16);
}
void flgr_vector_copy_fgUINT32_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgUINT32);
}
void flgr_vector_copy_fgUINT32_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgUINT64);
}
void flgr_vector_copy_fgUINT32_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgINT8);
}
void flgr_vector_copy_fgUINT32_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgINT16);
}
void flgr_vector_copy_fgUINT32_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgINT32);
}
void flgr_vector_copy_fgUINT32_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgINT64);
}
void flgr_vector_copy_fgUINT32_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgFLOAT32);
}
void flgr_vector_copy_fgUINT32_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT32,fgFLOAT64);
}


void flgr_vector_copy_fgUINT64_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64, fgBIT);
}
void flgr_vector_copy_fgUINT64_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgUINT8);
}
void flgr_vector_copy_fgUINT64_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64, fgUINT16);
}
void flgr_vector_copy_fgUINT64_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgUINT32);
}
void flgr_vector_copy_fgUINT64_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgUINT64);
}
void flgr_vector_copy_fgUINT64_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgINT8);
}
void flgr_vector_copy_fgUINT64_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgINT16);
}
void flgr_vector_copy_fgUINT64_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgINT32);
}
void flgr_vector_copy_fgUINT64_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgINT64);
}
void flgr_vector_copy_fgUINT64_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgFLOAT32);
}
void flgr_vector_copy_fgUINT64_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgUINT64,fgFLOAT64);
}


void flgr_vector_copy_fgINT8_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8, fgBIT);
}
void flgr_vector_copy_fgINT8_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgUINT8);
}
void flgr_vector_copy_fgINT8_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8, fgUINT16);
}
void flgr_vector_copy_fgINT8_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgUINT32);
}
void flgr_vector_copy_fgINT8_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8, fgUINT64);
}
void flgr_vector_copy_fgINT8_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgINT8);
}
void flgr_vector_copy_fgINT8_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgINT16);
}
void flgr_vector_copy_fgINT8_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgINT32);
}
void flgr_vector_copy_fgINT8_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgINT64);
}
void flgr_vector_copy_fgINT8_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgFLOAT32);
}
void flgr_vector_copy_fgINT8_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT8,fgFLOAT64);
}



void flgr_vector_copy_fgINT16_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16, fgBIT);
}
void flgr_vector_copy_fgINT16_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgUINT8);
}
void flgr_vector_copy_fgINT16_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16, fgUINT16);
}
void flgr_vector_copy_fgINT16_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgUINT32);
}
void flgr_vector_copy_fgINT16_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16, fgUINT64);
}
void flgr_vector_copy_fgINT16_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgINT8);
}
void flgr_vector_copy_fgINT16_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgINT16);
}
void flgr_vector_copy_fgINT16_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgINT32);
}
void flgr_vector_copy_fgINT16_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgINT64);
}
void flgr_vector_copy_fgINT16_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgFLOAT32);
}
void flgr_vector_copy_fgINT16_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT16,fgFLOAT64);
}



void flgr_vector_copy_fgINT32_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32, fgBIT);
}
void flgr_vector_copy_fgINT32_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgUINT8);
}
void flgr_vector_copy_fgINT32_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32, fgUINT16);
}
void flgr_vector_copy_fgINT32_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgUINT32);
}
void flgr_vector_copy_fgINT32_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32, fgUINT64);
}
void flgr_vector_copy_fgINT32_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgINT8);
}
void flgr_vector_copy_fgINT32_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgINT16);
}
void flgr_vector_copy_fgINT32_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgINT32);
}
void flgr_vector_copy_fgINT32_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgINT64);
}
void flgr_vector_copy_fgINT32_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgFLOAT32);
}
void flgr_vector_copy_fgINT32_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT32,fgFLOAT64);
}



void flgr_vector_copy_fgINT64_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64, fgBIT);
}
void flgr_vector_copy_fgINT64_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgUINT8);
}
void flgr_vector_copy_fgINT64_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64, fgUINT16);
}
void flgr_vector_copy_fgINT64_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgUINT32);
}
void flgr_vector_copy_fgINT64_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64, fgUINT64);
}
void flgr_vector_copy_fgINT64_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgINT8);
}
void flgr_vector_copy_fgINT64_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgINT16);
}
void flgr_vector_copy_fgINT64_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64, fgINT32);
}
void flgr_vector_copy_fgINT64_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgINT64);
}
void flgr_vector_copy_fgINT64_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgFLOAT32);
}
void flgr_vector_copy_fgINT64_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgINT64,fgFLOAT64);
}


void flgr_vector_copy_fgFLOAT32_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32, fgBIT);
}
void flgr_vector_copy_fgFLOAT32_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32,fgUINT8);
}
void flgr_vector_copy_fgFLOAT32_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32, fgUINT16);
}
void flgr_vector_copy_fgFLOAT32_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32,fgUINT32);
}
void flgr_vector_copy_fgFLOAT32_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32, fgUINT64);
}
void flgr_vector_copy_fgFLOAT32_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32,fgINT8);
}
void flgr_vector_copy_fgFLOAT32_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32,fgINT16);
}
void flgr_vector_copy_fgFLOAT32_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32, fgINT32);
}
void flgr_vector_copy_fgFLOAT32_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32, fgINT64);
}
void flgr_vector_copy_fgFLOAT32_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgFLOAT32);
}
void flgr_vector_copy_fgFLOAT32_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT32,fgFLOAT64);
}



void flgr_vector_copy_fgFLOAT64_fgBIT(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64, fgBIT);
}
void flgr_vector_copy_fgFLOAT64_fgUINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64,fgUINT8);
}
void flgr_vector_copy_fgFLOAT64_fgUINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64, fgUINT16);
}
void flgr_vector_copy_fgFLOAT64_fgUINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64,fgUINT32);
}
void flgr_vector_copy_fgFLOAT64_fgUINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64, fgUINT64);
}
void flgr_vector_copy_fgFLOAT64_fgINT8(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64,fgINT8);
}
void flgr_vector_copy_fgFLOAT64_fgINT16(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64,fgINT16);
}
void flgr_vector_copy_fgFLOAT64_fgINT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64, fgINT32);
}
void flgr_vector_copy_fgFLOAT64_fgINT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64, fgINT64);
}
void flgr_vector_copy_fgFLOAT64_fgFLOAT32(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY_TDEST_TSRC(fgFLOAT64,fgFLOAT32);
}
void flgr_vector_copy_fgFLOAT64_fgFLOAT64(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  FLGR_MACRO_VECTOR_COPY(fgFLOAT64);
}

//////////////////////////////////////////////////////////////////
// Macro for copying considering a fixed type for source
//////////////////////////////////////////////////////////////////
#define FLGR_MACRO_VECTOR_COPY_TEST_TYPE(dtype_src,			\
					 dtype1,dtype2,dtype3,dtype4,	\
					 dtype5,dtype6,dtype7,dtype8,	\
					 dtype9,dtype10,dtype11)	\
  									\
  if(flgr_vector_is_type_##dtype1(vctdest)) {				\
    flgr_vector_copy_##dtype1##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype2(vctdest)) {			\
    flgr_vector_copy_##dtype2##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype3(vctdest)) {			\
    flgr_vector_copy_##dtype3##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype4(vctdest)) {			\
    flgr_vector_copy_##dtype4##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype5(vctdest)) {			\
    flgr_vector_copy_##dtype5##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype6(vctdest)) {			\
    flgr_vector_copy_##dtype6##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype7(vctdest)) {			\
    flgr_vector_copy_##dtype7##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype8(vctdest)) {			\
    flgr_vector_copy_##dtype8##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype9(vctdest)) {			\
    flgr_vector_copy_##dtype9##_##dtype_src( vctdest , vctsrc);		\
									\
  }else if(flgr_vector_is_type_##dtype10(vctdest)) {			\
    flgr_vector_copy_##dtype10##_##dtype_src( vctdest , vctsrc);	\
									\
  }else if(flgr_vector_is_type_##dtype11(vctdest)) {			\
    flgr_vector_copy_##dtype11##_##dtype_src( vctdest , vctsrc);	\
									\
  }else error=1



//////////////////////////////////////////////////////////////////
/*! Copy a vector. If vectors types are differents, a cast will be made,
 *  but no normalization 
 *  @param vctdest : pointer to a FLGR_Vector 
 *  @param vctsrc  : pointer to a FLGR_Vector
 *  @returns FLGR_RET_OK, ...
 */
//////////////////////////////////////////////////////////////////
FLGR_Ret flgr_vector_copy(FLGR_Vector *vctdest, FLGR_Vector *vctsrc) {
  int error=0;
  FLGR_Ret ret;

  FLGR_DECLARE_FUNCTION;

  if((vctdest==NULL) || (vctsrc==NULL)) {
    POST_ERROR("Null objects!\n");
    return FLGR_RET_NULL_OBJECT;
  }
  
  if((ret=flgr_vector_is_same_spp(vctdest,vctsrc))!=FLGR_RET_OK) {
    POST_ERROR("Vector Size Different\n");
    return ret;
  }

  if(vctsrc->type==FLGR_UINT8) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgUINT8,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_UINT16) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgUINT16,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_UINT32) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgUINT32,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_UINT64) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgUINT64,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_INT8) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgINT8,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_INT16) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgINT16,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_INT32) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgINT32,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_INT64) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgINT64,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_FLOAT32) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgFLOAT32,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_FLOAT64) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgFLOAT64,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else if(vctsrc->type==FLGR_BIT) {
    FLGR_MACRO_VECTOR_COPY_TEST_TYPE(fgBIT,fgBIT,fgUINT8,fgUINT16,fgUINT32,fgUINT64,
				     fgINT8,fgINT16,fgINT32,fgUINT64,fgFLOAT32,fgFLOAT64);

  }else {
    error=1;
  }

  if(error==1) {
    POST_ERROR("type unknown!\n");
    return FLGR_RET_TYPE_UNKNOWN;
  }

  return FLGR_RET_OK;

}

















//! @}
